package com.ym.controller.patient.self;

/**
 * <简单描述>
 * <一句话描述>
 *
 * @author: 李涛
 * @version: 2019年05月14日 19:40
 */

import com.github.pagehelper.PageInfo;
import com.ym.common.constant.Constants;
import com.ym.core.annotation.ApiSign;
import com.ym.core.annotation.Log;
import com.ym.core.domain.APIResponse;
import com.ym.core.domain.BaseController;
import com.ym.core.shiro.ShiroUtil;
import com.ym.medical.domain.entity.FeedBackEntity;
import com.ym.medical.domain.entity.SysHelpEntity;
import com.ym.medical.domain.param.SysHelpParam;
import com.ym.medical.enums.FeeBackStateEnum;
import com.ym.medical.service.IFeedBackSV;
import com.ym.medical.service.IPatientCenterSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 我的家人
 *
 * @author: 李涛
 * @version: 2019年05月14日 19:36
 */
@Api(tags = "帮助信息查询接口")
@Controller
@ApiSign
@RequestMapping(value = "patient/self/help", headers = Constants.Api.VERSION)
public class HelpController extends BaseController {


	private static Logger logger = LoggerFactory.getLogger(HelpController.class);

	@Autowired
	private IPatientCenterSV iPatientCenterSV;

	@Autowired
	private IFeedBackSV feedBackSV;

	@Log(dataBase = false, printBody = false)
	@ApiOperation("帮助信息查询接口")
	@GetMapping(value = "/selectHelpInfo")
	@ResponseBody
	public APIResponse<PageInfo<SysHelpEntity>> selectHelpInfo(
			@ApiParam(name = "pageNo", value = "页码", required = true)
			@RequestParam(name = "pageNo", required = true, defaultValue = "1")
					int pageNo,
			@ApiParam(name = "limit", value = "每页数量", required = false)
			@RequestParam(name = "limit", required = false, defaultValue = "10")
					int limit,
			@ApiParam(name = "sysHelpModel", value = " 其中roleType 01患者端 02 医生端", required = true)
					SysHelpParam sysHelpModel) throws Exception {

		PageInfo<SysHelpEntity> sysHelps = iPatientCenterSV.selectHelpInfo(pageNo, limit, sysHelpModel);
		return successData(sysHelps);
	}

	@Log
	@ApiOperation("意见反馈")
	@PostMapping(value = "/feedBack/add")
	@ResponseBody
	public APIResponse insertfeedBack(@RequestBody FeedBackEntity feedBack) {
		/**默认为未处理状态*/
		feedBack.setState(FeeBackStateEnum.UN_PROCESSED.getKey());
		feedBack.setUserId(ShiroUtil.getLoginId());
		feedBackSV.insert(feedBack);
		return successData(feedBack);
	}


}
